package cn.wolfcode.luowowo.article.domain;
import cn.wolfcode.luowowo.common.domain.BaseDomain;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * 景点
 */
@Getter@Setter
public class Scenicspot extends BaseDomain{
    private String name;
    private String ename;
    private Long destId;
    private String destName;
    private String intro;
    private String coverUrl;
    private String images;
    private String catalog;
    private Long authorId;
    private String authorName;
    private Date lastUpdateTime;
    private String refScenicspot;   //关联的景点id
    private List<Scenicspot> insideScenicspots;   //关联的景点
    private Boolean ishot;          //是否是热门景点
    private String content;         //景点介绍内容
    private int beenNum;
    private int commentNum;

    public Long[] getScenicspotIds(){
        if(StringUtils.hasLength(refScenicspot)){
            String[] stringIds = refScenicspot.split(",");
            Long[] ids = new Long[stringIds.length];
            for (int i = 0; i < stringIds.length; i++) {
                ids[i] = Long.parseLong(stringIds[i]);
            }
            return ids;
        }
        return null;
    }

    public List<String> getImageList(){
        if(StringUtils.hasLength(images)){
            String[] strings = images.split(",");
            List<String> list = new ArrayList<>(strings.length);
            Collections.addAll(list, strings);
            return list;
        }
        return null;
    }
}